Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support multi-line node block in Visual Editor #2005

Merged
merged 37 commits into from
Feb 25, 2020

Conversation

yeze322
Copy link
Contributor

@yeze322 yeze322 commented Feb 18, 2020

Description

fixes #1701

Make the node block size-sensitive in Visual Editor: action flow's layout will change along with a single node block's size automatically.
(leverages the react-measure lib as a new dependency)

demo-multiline-node

More Context

Why we need this functionality?

In new action design, some $types have dynamic sizes. For example, when the prompt content inside a SendActivity node becomes very long, the node will have 2 or more lines to show full content.
image
image

This is a challenge to our layouter, we need to make the layout size-sensitive.

How it works?

  1. Wrap a child node with the 'react-measure' lib, it will fire an onResize event whenever its DOM size changes;
  2. Visual Editor maintains a layout computing chain, layout will be updated bottom-up via the onResize chain;
  3. A size-sensitive parent node do several things:
    • remembers child nodes' size and position
    • observes child nodes' size & recompute the layout once it receives new size
    • recompute its layout (node positions, edge length) & report its new size to higher level
    • redraw itself with the new layout (saved as states)
  4. After a node is measured, its size will be cached in a global cache. This will improve the flickering problem significantly.

What's changed?

  1. style: update the css of FormCard to make basic node blocks can show multiline text
  2. fix: reconnect the boundary propagation chain (onResize chain), it had been outdated for a while
  3. refactor: extract common layout logic as a new hook useSmartLayout, used to observe node sizes and recompute new layout when needed
  4. refactor: migrate widgets StepGroup, IfCondition, SwitchCondition, Foreach, Prompt to the new hook to make them size-sensitive
  5. feat: implement a global DesignerCache class for caching calculated node sizes

What's next?

  1. Alan is working on new node design, we will have a PR for new version of visual nodes
  2. I will keep optimizing UISchema especially the schema of ChoiceInput, hopefully in my next PR.
  3. lg hook is stll causing the flickering problem, waiting for Leilei's indexer work.

Task Item

#1701

Screenshots

image

@yeze322 yeze322 changed the title draft: support resizable node in Visual Editor draft: support multiline text in Visual Editor Feb 19, 2020
@yeze322 yeze322 changed the title draft: support multiline text in Visual Editor feat: implement size sensitive node block in Visual Editor Feb 20, 2020
@yeze322 yeze322 changed the title feat: implement size sensitive node block in Visual Editor feat: implement size-sensitive node block in Visual Editor Feb 20, 2020
@github-actions
Copy link

Coverage Status

Coverage increased (+0.3%) to 42.783% when pulling fefd425 on yeze322:visual/dynamic-layout into 3a9b11b on microsoft:master.

@yeze322 yeze322 changed the title feat: implement size-sensitive node block in Visual Editor feat: support multi-line node block in Visual Editor Feb 24, 2020
@a-b-r-o-w-n a-b-r-o-w-n merged commit 7b452d3 into microsoft:master Feb 25, 2020
@cwhitten
Copy link
Member

cwhitten commented Feb 26, 2020 via email

@yeze322
Copy link
Contributor Author

yeze322 commented Feb 26, 2020

@cwhitten No there isn't. Maybe we can add a max-height css property to limit the bounds?

@cwhitten
Copy link
Member

cwhitten commented Feb 26, 2020 via email

@yeze322
Copy link
Contributor Author

yeze322 commented Feb 26, 2020

@cwhitten that's right, let me update some css

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants